//
//  DYSubTagCell.m
//  BaiSi
//
//  Created by mac on 16/10/17.
//  Copyright © 2016年 DeYi. All rights reserved.
//

#import "DYSubTagCell.h"
#import "DYSubTagItem.h"
#import "DYRightItem.h"

#import <SDWebImage/UIImageView+WebCache.h>
#import "UIImage+circleImage.h"

@interface DYSubTagCell ()
@property (weak, nonatomic) IBOutlet UIImageView *iconImage;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *subTitleLabel;
@property (weak, nonatomic) IBOutlet UIButton *recomendBtn;

@end
@implementation DYSubTagCell



-(void)setFrame:(CGRect)frame {
    
    frame.size.height -= 1;
    [super setFrame:frame];
}

- (void)setRightConcernItem:(DYRightItem *)rightConcernItem {
    _rightConcernItem = rightConcernItem;
    [_iconImage sd_setImageWithURL:[NSURL URLWithString:rightConcernItem.header] placeholderImage:[UIImage imageNamed:@"defaultUserIcon"]completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
        
        if (image == nil) return ;
        //获取圆形图片
        _iconImage.image = [UIImage circleImageWithImage:image];
    }];
    _titleLabel.text = rightConcernItem.screen_name;
    NSInteger num = rightConcernItem.fans_count;
    //    LHLog(@"%zd",num);
    if (num >=10000) {
        _subTitleLabel.text = [NSString stringWithFormat:@"%0.1f万人关注",(num / 10000.0)];
        _subTitleLabel.text = [ _subTitleLabel.text stringByReplacingOccurrencesOfString:@".0" withString:@""];
    }else {
        _subTitleLabel.text = [NSString stringWithFormat:@"%ld人关注",(long)num ];
        
    }
}
-(void)setItem:(DYSubTagItem *)item {
    _item = item;
    [_iconImage sd_setImageWithURL:[NSURL URLWithString:item.image_list] placeholderImage:[UIImage imageNamed:@"defaultUserIcon"]completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
        
        if (image == nil) return ;
      //获取圆形图片
        _iconImage.image = [UIImage circleImageWithImage:image];
    }];
    _titleLabel.text = item.theme_name;
    NSInteger num = item.sub_number.integerValue;
//    LHLog(@"%zd",num);
    if (num >=10000) {
        _subTitleLabel.text = [NSString stringWithFormat:@"%0.1f万人订阅",(num / 10000.0)];
        _subTitleLabel.text = [ _subTitleLabel.text stringByReplacingOccurrencesOfString:@".0" withString:@""];
    }else {
        _subTitleLabel.text = [NSString stringWithFormat:@"%ld人订阅",(long)num ];
        
    }
    
}

#pragma mark - 点击订阅
- (IBAction)recommendButtonClick:(id)sender {
    
    LHLog(@"点击订阅");
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
